function  cancel(){
    var index = parent.layer.getFrameIndex(window.name);
    parent.layer.close(index);
}
function confirm() {   //获取省市县/区在area.js配置的地区编码
    var a = 	$(".layui-anim-upbit");
    var arr = new Array();
    $.each(a,function(){
        let attr =	$(this).find(".layui-this").text();
        arr.push(attr)
    })
    let val = $("#demo").val();

    console.log(val)
    if (arr[0] == '' || arr == undefined){
        alert("请选择省区域")
    }else if( arr[1] == '' || arr == undefined){
        alert("请选择市区域")
    }else if( arr[2] == '' || arr == undefined){
        alert("请选择县")
    }
    else if( val == '' || val == undefined){
        alert("详情信息不得为空")
    }else if(arr[0] != "" && arr[1] != "" && arr[2] != "" && val != ""){
          var orderId=  parent.$("#orderId").val();
        $.ajax({
            type:"post",
            url:"/order/intermediate/addRess",
            data:{"orderSite":arr[0],"orderCity":arr[1],"orderDistrict":arr[2],"orderDetail":val,"orderId":orderId},
            dataType:"json",
            success:function (res){
                var index = parent.layer.getFrameIndex(window.name);
                var _value = arr[0]+""+arr[1]+""+arr[2]+""+val

                console.log(arr[0]+""+arr[1]+""+arr[2]+""+val);
                parent.address(_value)
                parent.Refresh();
                parent.layer.close(index);
            }
        })

    }
    console.log(arr)

}
var areaData = Area;
var $form;
var form;
var $;
layui.use(['jquery', 'form'], function() {
    $ = layui.jquery;
    form = layui.form;
    $form = $('form');
    loadProvince();
});
//加载省数据   '_' + areaData[i].mallCityList.length + '_' + i +
function loadProvince() {
    var proHtml = '';
    for (var i = 0; i < areaData.length; i++) {
        proHtml += '<option value="' + areaData[i].provinceCode + '_' + areaData[i].mallCityList.length + '_' + i +'">' + areaData[i].provinceName + '</option>';
    }
    //初始化省数据
    $form.find('select[name=province]').append(proHtml);
    form.render();
    form.on('select(province)', function(data) {
        $form.find('select[name=area]').html('<option value="">请选择县/区</option>').parent();
        var value = data.value;
        var d = value.split('_');
        var code = d[0];
        var count = d[1];
        var index = d[2];
        if (count > 0) {
            loadCity(areaData[index].mallCityList);
        } else {
            $form.find('select[name=city]').parent();
        }
    });
}
//加载市数据   '_' + citys[i].mallAreaList.length + '_' + i +
function loadCity(citys) {
    var cityHtml = '';
    for (var i = 0; i < citys.length; i++) {
        cityHtml += '<option value="' + citys[i].cityCode + '_' + citys[i].mallAreaList.length + '_' + i +'">' + citys[i].cityName + '</option>';
    }
    $form.find('select[name=city]').html(cityHtml).parent();
    form.render();
    form.on('select(city)', function(data) {
        var value = data.value;
        var d = value.split('_');
        var code = d[0];
        var count = d[1];
        var index = d[2];
        if (count > 0) {
            loadArea(citys[index].mallAreaList);
        } else {
            $form.find('select[name=area]').parent();

        }
    });
}
//加载县/区数据
function loadArea(areas) {
    var areaHtml = '';
    for (var i = 0; i < areas.length; i++) {
        areaHtml += '<option value="' + areas[i].areaCode + '">' + areas[i].areaName + '</option>';
    }
    $form.find('select[name=area]').html(areaHtml).parent();
    form.render();
    form.on('select(area)', function(data) {
    });
}
